package Tools;
  
import com.opensymphony.xwork2.ActionSupport;
import com.opensymphony.xwork2.validator.annotations.*;
 

@Validation
  
public class RegistrationAction extends ActionSupport 
{

      
	private String username = null;
	private String usermail = null;
	private String usermailconfirm = null;
	private String password = null;
	private String passwordconfirm = null;

    
	@RequiredStringValidator(message="Supply name")
  
	public String getUsername() 
	{
		return username;
	}
	
	public void setUsername(String value) 
	{
		username = value;
	}
  
	@RequiredStringValidator(message="Supply Email")
  
	public String getUsermail() 
	{
		return usermail;
	}

	public void setUsermail(String value) 
	{
		usermail = value;
	}

	@RequiredStringValidator(message="Supply Email Confirmation")
  
	public String getUsermailconfirm() 
	{

		return usermailconfirm;
	}
	
	public void setUsermailconfirm(String value) 
	{

		usermailconfirm = value;
	}
  
	@RequiredStringValidator(message="Supply password")

	public String getPassword() 
	{   
		return password;
	}
	
	public void setPassword(String value) 
	{    
		password = value;
	}

	@RequiredStringValidator(message="Supply password confirmation")

	public String getPasswordconfirm() 
	{   
		return passwordconfirm;
	}
	
	public void setPasswordconfirm(String value) 
	{    
		passwordconfirm = value;
	}
    
    
   
	public String execute() throws Exception 
	{
        
		//System.out.println("Validating login");
		if(!getUsermail().equals(getUsermailconfirm()))
		{
			addActionError("the emails dont match! Please try again!");
			return ERROR;
		}
		else if (!getPasswordconfirm().equals(getPassword()))
		{
			addActionError("the passwords dont match! Please try again!");
			return ERROR;
		}
		else
		{
			return SUCCESS;
		}
	}
} 